<template>
  <!--
          描述：今日福利统计
      -->
  <div class="user">
    <!--搜索表单-->
    <div class="common-seach-wrap">
      <el-form size="small" :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="选择日期"> <el-date-picker v-model="formInline.date" type="daterange" value-format="yyyy-MM-dd" placeholder="选择日期">
       </el-date-picker></el-form-item>
        <el-form-item><el-button type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button>
        <el-button type="primary" icon="el-icon-search" @click="onPush">导出</el-button>
        </el-form-item>

      </el-form>
    </div>
    <!--内容-->
    <div class="product-content">
      <div class="table-wrap">
        <el-table size="small" :data="tableData" border style="width: 100%" v-loading="loading">
          <el-table-column prop="gap" label="日期"></el-table-column>
          <el-table-column prop="num" label="订单数量"></el-table-column>

        </el-table>
      </div>

    </div>
  </div>
</template>

<script>
import WelwfreApi from '@/api/welfare.js';
export default {

  data() {
    return {
      /*是否加载完成*/
      loading: true,
      /*列表数据*/
      tableData: [],
      /*一页多少条*/
      pageSize: 15,
      /*一共多少条数据*/
      totalDataNumber: 0,
      /*当前是第几页*/
      curPage: 1,
      /*横向表单数据模型*/
      formInline: {
        date: ''
      },
      /*是否打开添加弹窗*/
      open_add: false,
      /*是否打开编辑弹窗*/
      open_edit: false,
      /*当前编辑的对象*/
      userModel: {},

    };
  },
  created() {
    /*获取列表*/
    this.getTableList();
  },
  methods: {
    /*选择第几页*/
    handleCurrentChange(val) {
      let self = this;
      self.curPage = val;
      self.loading = true;
      self.getTableList();
    },

    /*每页多少条*/
    handleSizeChange(val) {
      this.curPage = 1;
      this.pageSize = val;
      this.getTableList();
    },

    /*获取列表*/
    getTableList() {
      let self = this;
      let Params = self.formInline;
      Params.page = self.curPage;
      Params.type = 1;
      Params.list_rows = self.pageSize;
      WelwfreApi.getListCount(Params, true)
        .then(data => {
          self.loading = false;
          self.tableData = data.data.info;
        })
        .catch(error => {
          self.loading = false;
        });
    },

    /*搜索查询*/
    onSubmit() {
      let self = this;
      self.loading = true;
      let Params = self.formInline;
      self.getTableList();
    },

    /*打开添加*/
    addClick(item) {
      this.userModel = item;
      this.open_add = true;
    },
    onPush(){
      let self = this;
      let Params = self.formInline;
      Params.type = 1;
      WelwfreApi.push(Params, true)
        .then(data => {
          let path = data.data.path;
          window.location.href = path;
        })
        .catch(error => {
          self.loading = false;
        });
    },

  }
};
</script>
<style></style>
